package com.sudichina.sudichina.view.activity.qiangdan;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.amap.api.maps.AMap;
import com.amap.api.maps.MapView;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.Marker;
import com.amap.api.maps.model.MarkerOptions;
import com.amap.api.services.core.AMapException;
import com.amap.api.services.core.LatLonPoint;
import com.amap.api.services.route.BusRouteResult;
import com.amap.api.services.route.DrivePath;
import com.amap.api.services.route.DriveRouteResult;
import com.amap.api.services.route.RideRouteResult;
import com.amap.api.services.route.RouteSearch;
import com.amap.api.services.route.WalkRouteResult;
import com.google.common.reflect.TypeToken;
import com.sudichina.sudichina.Contains;
import com.sudichina.sudichina.MyApp;
import com.sudichina.sudichina.NET.Api;
import com.sudichina.sudichina.NET.NetUtils;
import com.sudichina.sudichina.NET.onRequestDataFinish;
import com.sudichina.sudichina.R;
import com.sudichina.sudichina.bean.Result;
import com.sudichina.sudichina.bean.TCarOwnOrderVO;
import com.sudichina.sudichina.bean.TConsignorOrderVO;
import com.sudichina.sudichina.bean.YueCheList;
import com.sudichina.sudichina.entity.TSubmitOrderVO;
import com.sudichina.sudichina.utils.DialogFrameAnimUtils;
import com.sudichina.sudichina.utils.StringUtils;
import com.sudichina.sudichina.utils.Toastutils;
import com.sudichina.sudichina.view.activity.login.LoginActivity;
import com.sudichina.sudichina.view.activity.main.BaseActivity;
import com.sudichina.sudichina.view.activity.orlder.MyOrlderActivity;
import com.sudichina.sudichina.view.activity.wallet.WalletActivity;
import com.sudichina.sudichina.view.gaode.myview.DrivingRouteOverLay;
import com.sudichina.sudichina.view.gaode.util.AMapUtil;
import com.sudichina.sudichina.view.gaode.util.GaoDeToastUtils;

import java.io.IOException;
import java.lang.reflect.Type;
import java.text.Format;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.sudichina.sudichina.R.id.gallery;

/**
 * Created by ${杨伟乔} on 2017/3/9.
 * 邮箱: yangweiqiao@126.com
 * QQ: 463217558
 * 别人光鲜的背后或者有着太多不为人知的痛苦
 * 学习可以改变一切、 行动可以解决一切问题、
 */
public class QiangdanActivity extends BaseActivity implements RouteSearch.OnRouteSearchListener, AMap.OnMapClickListener, AMap.OnMarkerClickListener, AMap.OnInfoWindowClickListener, AMap.InfoWindowAdapter, onRequestDataFinish, AMap.OnMapTouchListener {


    @BindView(R.id.iv_back)
    ImageView ivBack;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_right)
    TextView tvRight;
    @BindView(R.id.page_container)
    RelativeLayout pageContainer;
    @BindView(R.id.ll_qiangdan)
    LinearLayout llQiangdan;


    @BindView(R.id.ll_mark_item1)
    public LinearLayout llMarkItem1;


    @BindView(R.id.mv_map)
    //高德地图使用的变量
    public MapView mapView;
    @BindView(R.id.tv_chufadi)
    TextView privateTvChufadi;
    @BindView(R.id.tv_starttimes)
    TextView privateTvStarttimes;
    @BindView(R.id.tv_mudidi)
    TextView privateTvMudidi;
    @BindView(R.id.tv_endtimes)
    TextView privateTvEndtimes;
    @BindView(R.id.tv_goodstype)
    TextView privateTvGoodstype;
    @BindView(R.id.tv_goodsname)
    TextView privateTvGoodsname;
    @BindView(R.id.tv_goodsweight)
    TextView privateTvGoodsweight;
    @BindView(R.id.tv_goodstiji)
    TextView privateTvGoodstiji;
    @BindView(R.id.tv_zhengcheprice)
    TextView privateTvZhengcheprice;
    @BindView(R.id.tv_fuwu)
    TextView privateTvboxFuwu;
    @BindView(R.id.tv_fapiao)
    TextView privateTvboxFapiao;
    @BindView(R.id.scrollView)
    ScrollView privateScrollView;
    @BindView(R.id.btn_ok)
    public Button privateBtnOk;
    @BindView(R.id.tv_qiangdan_chepai)
    TextView tvQiangdanChepai;
    @BindView(R.id.tv_qiangdan_price)
    TextView tvQiangdanPrice;
    @BindView(gallery)
    Gallery privateGallery;

    private LatLonPoint mStartPoint = new LatLonPoint(39.942295, 116.335891);//起点，116.335891,39.942295
    private LatLonPoint mEndPoint = new LatLonPoint(42.995576, 110.481288);//终点，116.481288,39.995576

    //TODO
    private LatLonPoint latLonPoint = new LatLonPoint(41.90865, 116.39751);//途经点
    List<LatLonPoint> addWayCityList = new ArrayList<>();
    private AMap aMap;
    private RouteSearch mRouteSearch;
    private final int ROUTE_TYPE_DRIVE = 2;
    private Context mContext;
    private DriveRouteResult mDriveRouteResult;
    private ProgressDialog progDialog;
    private List<YueCheList.DataBean.ContentBean> yuecheOrlderList;
    private Long id;
    private int carID;
    private TCarOwnOrderVO carOrderVo;
    private TConsignorOrderVO consignorOrderVo;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_qiangdan);
        ButterKnife.bind(this);

        //登录检测
        LoginActivity.startMeAndInitIsLogin(this, Contains.QIANGDAN_EXTRA);

        mContext = this.getApplicationContext();
        //获取地图控件引用
        //在activity执行onCreate时执行mMapView.onCreate(savedInstanceState)，创建地图
        mapView.onCreate(savedInstanceState);
        initMap();
        tvTitle.setText("抢单");
        Intent intent = getIntent();
        try {
            carID = intent.getIntExtra("CarID", 0);
            String carNUmber = (String) intent.getCharSequenceExtra("CarNUmber");
            System.out.println("车牌是:" + carNUmber + "车辆的ID是:" + carID);
            tvQiangdanChepai.setText(carNUmber);
        } catch (Exception e) {
        }


        initView();
        initDatas();

    }


    @Override
    public void onBackPressed() {
        //判断当前的对话框是否为打开的状态
        if (llMarkItem1.getVisibility() == View.GONE || llMarkItem1.getVisibility() == View.INVISIBLE) {
            //如果是打开的状态  关闭菜单
            super.onBackPressed();
        } else {
            //如果不是打开的状态 执行原来的效果
            llMarkItem1.setVisibility(View.GONE);
            privateBtnOk.setEnabled(false);

        }
    }

    /**
     * 初始化AMap对象
     */
    private void initMap() {
        if (aMap == null) {
            aMap = mapView.getMap();
        }
        aMap.setOnMapClickListener(this);
        aMap.setOnMarkerClickListener(this);
        aMap.setOnInfoWindowClickListener(this);
        aMap.setInfoWindowAdapter(this);
        mRouteSearch = new RouteSearch(this);
        mRouteSearch.setRouteSearchListener(this);

        aMap.addMarker(new MarkerOptions()
                .position(AMapUtil.convertToLatLng(mStartPoint))
                .icon(BitmapDescriptorFactory.fromResource(R.drawable.green_point)));
        aMap.addMarker(new MarkerOptions()
                .position(AMapUtil.convertToLatLng(mEndPoint))
                .icon(BitmapDescriptorFactory.fromResource(R.drawable.red_point)));
        searchRouteResult(ROUTE_TYPE_DRIVE, RouteSearch.DrivingDefault);
        /**
         * 解决手势冲突的问题
         */
        aMap.setOnMapTouchListener(this);
    }

    private void initDatas() {
        if (MyApp.getCurrentUser() == null) {
            return;
        }


        /**
         * 加载数据 currentPage 当前页；
         pageSize 每页大小
         */
        System.out.println("加载数据");
        HashMap<String, Object> map = new HashMap<>();
        map.put("tradeStatus", Contains.YUECHEDAIQIANG);
        map.put("currentPage", 1);
        map.put("pageSize", 1000);

        Type type = new TypeToken<YueCheList>() {
        }.getType();
        NetUtils.requestData(Api.YUECHELIST, map, this, type, true);

    }

    private void initView() {


    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        //在activity执行onDestroy时执行mMapView.onDestroy()，销毁地图
        mapView.onDestroy();
    }

    @Override
    protected void onResume() {
        super.onResume();
        //在activity执行onResume时执行mMapView.onResume ()，重新绘制加载地图
        mapView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        //在activity执行onPause时执行mMapView.onPause ()，暂停地图的绘制
        mapView.onPause();
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        //在activity执行onSaveInstanceState时执行mMapView.onSaveInstanceState (outState)，保存地图当前的状态
        mapView.onSaveInstanceState(outState);
    }


    @Override
    public void onRideRouteSearched(RideRouteResult rideRouteResult, int i) {

    }

    @Override
    public View getInfoContents(Marker arg0) {
        return null;
    }

    @Override
    public View getInfoWindow(Marker arg0) {
        return null;
    }

    @Override
    public void onInfoWindowClick(Marker arg0) {

    }

    @Override
    public boolean onMarkerClick(Marker arg0) {
        return false;
    }

    @Override
    public void onMapClick(LatLng arg0) {

    }

    /**
     * 开始搜索路径规划方案
     */
    public void searchRouteResult(int routeType, int mode) {
        if (mStartPoint == null) {
            GaoDeToastUtils.show(this, "定位中，稍后再试...");
            return;
        }
        if (mEndPoint == null) {
            GaoDeToastUtils.show(mContext, "终点未设置");
        }
        showProgressDialog();
        final RouteSearch.FromAndTo fromAndTo = new RouteSearch.FromAndTo(
                mStartPoint, mEndPoint);
        if (routeType == ROUTE_TYPE_DRIVE) {// 驾车路径规划
            //
            RouteSearch.DriveRouteQuery query = new RouteSearch.DriveRouteQuery(fromAndTo, mode, addWayCityList,
                    null, "");// 第一个参数表示路径规划的起点和终点，第二个参数表示驾车模式，第三个参数表示途经点，第四个参数表示避让区域，第五个参数表示避让道路
            mRouteSearch.calculateDriveRouteAsyn(query);// 异步路径规划驾车模式查询
        }
    }

    @Override
    public void onBusRouteSearched(BusRouteResult result, int errorCode) {

    }

    @Override
    public void onDriveRouteSearched(DriveRouteResult result, int errorCode) {
        dissmissProgressDialog();
        aMap.clear();// 清理地图上的所有覆盖物
        if (errorCode == AMapException.CODE_AMAP_SUCCESS) {
            if (result != null && result.getPaths() != null) {
                if (result.getPaths().size() > 0) {
                    mDriveRouteResult = result;
                    final DrivePath drivePath = mDriveRouteResult.getPaths()
                            .get(0);
                    DrivingRouteOverLay drivingRouteOverlay = new DrivingRouteOverLay(
                            mContext, aMap, drivePath,
                            mDriveRouteResult.getStartPos(),
                            mDriveRouteResult.getTargetPos(), null);
                    drivingRouteOverlay.setNodeIconVisibility(false);//设置节点marker是否显示
                    drivingRouteOverlay.setIsColorfulline(true);//是否用颜色展示交通拥堵情况，默认true
                    drivingRouteOverlay.removeFromMap();
                    drivingRouteOverlay.addToMap();
                    drivingRouteOverlay.zoomToSpan();
//                    mBottomLayout.setVisibility(View.VISIBLE);
                    int dis = (int) drivePath.getDistance();
                    int dur = (int) drivePath.getDuration();
                    String des = AMapUtil.getFriendlyTime(dur) + "(" + AMapUtil.getFriendlyLength(dis) + ")";
//                    mRotueTimeDes.setText(des);
//                    mRouteDetailDes.setVisibility(View.VISIBLE);
                    int taxiCost = (int) mDriveRouteResult.getTaxiCost();
//                    mRouteDetailDes.setText("打车约"+taxiCost+"元");
//                    mBottomLayout.setOnClickListener(new View.OnClickListener() {
//                        @Override
//                        public void onClick(View v) {
//                            Intent intent = new Intent(mContext,
//                                    DriveRouteDetailActivity.class);
//                            intent.putExtra("drive_path", drivePath);
//                            intent.putExtra("drive_result",
//                                    mDriveRouteResult);
//                            startActivity(intent);
//                        }
//                    });
                } else if (result != null && result.getPaths() == null) {
                    GaoDeToastUtils.show(mContext, R.string.no_result);
                }

            } else {
                GaoDeToastUtils.show(mContext, R.string.no_result);
            }
        } else {
            GaoDeToastUtils.showerror(this.getApplicationContext(), errorCode);
        }


    }

    @Override
    public void onWalkRouteSearched(WalkRouteResult result, int errorCode) {

    }


    /**
     * 显示进度框
     */
    private void showProgressDialog() {
        if (progDialog == null)
            progDialog = new ProgressDialog(this);
        progDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        progDialog.setIndeterminate(false);
        progDialog.setCancelable(true);
        progDialog.setMessage("正在搜索");
        progDialog.show();
    }

    /**
     * 隐藏进度框
     */
    private void dissmissProgressDialog() {
        if (progDialog != null) {
            progDialog.dismiss();
        }
    }

    private int current;

    public GalleryAdapter adapter = null;
    public int selectNum = 0;//全局变量，保存被选中的item

    @Override
    public void requestdataFinish(String catalog, Object bean) {

        switch (catalog) {
            case Api.YUECHELIST:
                YueCheList data = (YueCheList) bean;
                Toastutils.showToast(data.getMsg());
                System.out.println(data);

                int code = data.getCode();
//// TODO: 2017/3/26 修改
                if (code == 1) {
                    //成功
                    //判断数据

                    yuecheOrlderList = data.getData().getContent();


                    int size = yuecheOrlderList.size();

                    System.out.println("一共有多少条约车的数据:" + size);


                    List<Drawable> list = new ArrayList<>();

                    for (int i = 0; i < yuecheOrlderList.size(); i++) { //// TODO: 2017/3/26
                        list.add(getResources().getDrawable(R.mipmap.icon_01));


                    }

                    adapter = new GalleryAdapter(this, list);

                    privateGallery.setAdapter(adapter);
                    current = (int) (0);
                    privateGallery.setSelection(current);// 设置默认显示的图片
                    privateGallery.setOnItemSelectedListener(new Gallery.OnItemSelectedListener() {

                        @Override
                        public void onItemSelected(AdapterView<?> arg0, View arg1,
                                                   int arg2, long arg3) {
                            System.out.println(arg2);
                            selectNum = arg2;//
                            adapter.notifyDataSetChanged();
                        }

                        @Override
                        public void onNothingSelected(AdapterView<?> arg0) {
                            System.out.println("not");
                        }
                    });

                    privateGallery.setOnItemClickListener(new Gallery.OnItemClickListener() {

                        @Override
                        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                                                long arg3) {
                        }
                    });


                }


                break;

            case Api.ROBTORDER:


                Result bean1 = (Result) bean;
                System.out.println("抢单的结果是:" + bean1.getCode() + "   " + bean1.getMsg());

                if (bean1.getCode() == 1) {
                    //抢单成功
                    DialogFrameAnimUtils.startSucessAnim(getApplicationContext(), this, "抢单成功");
                    new Handler().postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            startActivity(new Intent(QiangdanActivity.this, MyOrlderActivity.class));
                            finish();
                        }
                    }, 2000);

                } else if (bean1.getCode() == 8020) {
                    //余额不足  提示用户去充值  // TODO: 2017/3/27
                    //弹出一个提示的对话框
                    System.out.println("账户余额不足,扣除保证金失败!");
                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.setTitle("提示:");
                    builder.setMessage("账户余额不足,扣除保证金失败!");


                    builder.setPositiveButton("去充值", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // TODO: 2017/3/27
                            startActivity(new Intent(QiangdanActivity.this, WalletActivity.class));

                        }
                    });
                    builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {

                        }
                    });


                    //builder创建对话框对象AlertDialog
                    AlertDialog simpledialog = builder.create();
                    simpledialog.show();


                } else if (bean1.getCode() == 8025) {

                    //8025   该订单已被抢

                    Toastutils.showToast("该订单已经被抢");
                }

                break;
        }


    }

    @Override
    public void requestdataFailed(IOException e) {
        System.out.println("结果回调失败 :" + e);
    }


    public void onClickPosition(int s) {
        /**
         * 这个方法里面  根据位置来更新数据
         */

        if (yuecheOrlderList == null || yuecheOrlderList.size() == 0) {
            //没有约车的订单  返回
            return;
        }
        System.out.println("点击位置:" + s);
        privateBtnOk.setEnabled(true);
        llMarkItem1.setVisibility(View.VISIBLE);
        YueCheList.DataBean.ContentBean contentBean = yuecheOrlderList.get(s);
        id = contentBean.getId();
/**
 *
 * [
 {
 //收货人
 "consignee": "蔺腾飞",
 //收货人地址
 "consigneeAdd": "北京市/北京市/顺义区",

 //当前页面
 "currentPage": 1,
 //发货人
 "deliverAddress": "赵小虎",
 //门到站
 "deliverFlag": "doorToStation",
 //发货金钱
 "deliverMoney": 12,
 //发货结束区域
 "endZone": "大兴区",
 //发货开始区域
 "fromZone": "昌平区",
 //货物名称
 "itemName": "阿莫西林",
 //订单金钱
 "orderMoney": 156,
 //总价格
 "totalMoney": 173.16,
 //单价
 "unitPrice": 12,
 //重量
 "weight": 12
 *
 */
        System.out.println("----"+contentBean.getEndZone());
        privateTvChufadi.setText(contentBean.getFromZone().trim());//始发地
        privateTvMudidi.setText(contentBean.getEndZone().trim());//结束地
        String date = StringUtils.formatDate(contentBean.getTransStartTime() + "");
        String date2 = StringUtils.formatDate(contentBean.getTransEndTime() + "");
        privateTvStarttimes.setText(date);//时间
        privateTvEndtimes.setText(date2);//结束时间
        privateTvGoodstype.setText("货物类型:" + contentBean.getItemName());//货物类型
        privateTvGoodsname.setText("货物名称:" + contentBean.getItemName());//货物名称
        privateTvGoodsweight.setText("货物重量:" + contentBean.getWeight() + "吨");//重量
        privateTvGoodstiji.setText("货物体积:" + contentBean.getWeight() + "");//体积
        privateTvZhengcheprice.setText("报价: " + contentBean.getTotalMoney() + "元");
        switch (contentBean.getDeliverFlag()) {
            case "doorToStation":
                privateTvboxFuwu.setText("门到站");
                break;
            case "doorToDoor":
                privateTvboxFuwu.setText("门到门");
                break;
            case "stationToDoor":
                privateTvboxFuwu.setText("站到门");
                break;
            case "stationToStation":
                privateTvboxFuwu.setText("站到站");
                break;

        }

        tvQiangdanPrice.setText(contentBean.getTotalMoney() + "元");


    }

    /**
     * 解决高德地图和ScrollView冲突的问题
     *
     * @param motionEvent
     */
    @Override
    public void onTouch(MotionEvent motionEvent) {

        int action = motionEvent.getAction();
        switch (action) {
            case MotionEvent.ACTION_UP:
                privateScrollView.requestDisallowInterceptTouchEvent(false);
                break;
            case MotionEvent.ACTION_DOWN:
            case MotionEvent.ACTION_MOVE:
                privateScrollView.requestDisallowInterceptTouchEvent(true);
                break;
        }

    }

    @OnClick({R.id.iv_back, R.id.btn_ok})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                onBackPressed();
                break;
            case R.id.btn_ok:
                //弹出一个提示的对话框
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
                builder.setTitle("提示:");
                builder.setMessage("抢单需要交纳保证金,保证金的金额是订单的10%,直接从余额里面扣除,点击确定按钮表示同意抢单!");

                //为builder对象添加确定按钮，不过这里嵌套了一个函数
                builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        querenqiangdan();
                    }
                });
                builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                    }
                });


                //builder创建对话框对象AlertDialog
                AlertDialog simpledialog = builder.create();
                simpledialog.show();

                break;
        }
    }

    private void querenqiangdan() {
        /**
         * 确认提交
         */

        /**
         * 车主的id
         * 车的id
         * 订单详情的id
         */

        TSubmitOrderVO entity = new TSubmitOrderVO();
        carOrderVo = new TCarOwnOrderVO();
        consignorOrderVo = new TConsignorOrderVO();
        carOrderVo.setCarId(Long.valueOf(carID));
        carOrderVo.setVehAccountId(MyApp.getCurrentUser().getId());
        consignorOrderVo.setId(String.valueOf(id));
        entity.settCarOrderVo(carOrderVo);
        entity.settConsignorOrderVo(consignorOrderVo);
        entity.settOrderItemVo(null);
        Type type = new TypeToken<Result>() {
        }.getType();
        NetUtils.requestDataformentity(Api.ROBTORDER, entity, this, type);
    }

    public class GalleryAdapter extends BaseAdapter {
        public List<Drawable> list = null;
        public Context ctx = null;

        public GalleryAdapter(Context ctx, List<Drawable> list) {
            this.list = list;
            this.ctx = ctx;
        }

        @Override
        public int getCount() {
            return list.size();
        }

        @Override
        public Object getItem(int position) {
            return list.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            final ViewHolder holder;
            if (convertView == null) {
                holder = new ViewHolder();
                convertView = View.inflate(ctx, R.layout.image_item, null);
                holder.image = (ImageView) convertView.findViewById(R.id.image);
                holder.imageRel = (RelativeLayout) convertView.findViewById(R.id.image_rel);
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }

            holder.image.setImageDrawable(list.get(position));
            if (selectNum == position) {
                // android.widget.Toast.makeText(ctx, "position:"+position, Toast.LENGTH_SHORT).show();

                onClickPosition(position);
                holder.image.setLayoutParams(new RelativeLayout.LayoutParams(210, 210));//如果被选择则放大显示
                holder.image.setAlpha(250);
            } else {
                holder.image.setLayoutParams(new RelativeLayout.LayoutParams(150, 150));//否则正常
                holder.image.setAlpha(100);
            }
            return convertView;
        }

    }

    class ViewHolder {
        ImageView image;
        RelativeLayout imageRel;
    }


}
